package net.flyinggroup.si.model;

import lombok.Builder;
import lombok.Getter;
import lombok.ToString;

@Getter
@ToString
@Builder
public class Cargo {
    private long trackingId;
    private String receiverName;
    private String deliveryAddress;
    private double weight;
    private String description;
    private ShippingType shippingType;
    private int deliveryDayCommitment;
    private int region;

    public enum ShippingType {
        DOMESTIC, INTERNATIONAL
    }

    public static class CargoBuilder {
        public Cargo build() {
            if ((shippingType == ShippingType.DOMESTIC) && (region <= 0 || region > 4)) {
                throw new IllegalStateException("Region is invalid! Cargo tracking Id: " + trackingId);
            }
            return new Cargo(trackingId, receiverName, deliveryAddress, weight, description, shippingType, deliveryDayCommitment, region);
        }
    }
}
